
public class Ship {
	/**
	 * ship is a holder of the squares it occupies
	 * ship keeps track of horizontal and vertical placements throughout the game
	 * called by Game class
	 * 
	 * we should ask ship if we hit or missed it with our guess.
	 * 
	 * ship should update the statistics of the ideal square
	 * if we had multiple ships we should make a class called fleet to hold all the different ships
	 * and then fleet would check with its ships to see if we hit or missed.
	 * 
	 * @author Larry Savago
	 * @author Casey Huckins
	 * @date 4/13/2012
	 *
	 */

	
	public static final int SIZE = 3;
	private Square[] myShip = new Square[SIZE];
	private Square[] targetShip = new Square[SIZE];
	private boolean orientation = false; // horizontal
	private int hits = 0;
	private int sinks = 0;
	private int horizontals = 0;
	private int verticals = 0;

	
	public void buildShip(Square[] s) {
		myShip = s;
	}
	
	public void setOrientation(boolean o) {
		orientation = o;
	}
	
	public boolean getOrientation() {
		return orientation;
	}
	public void set(int i, Square s) {
		myShip[i] = s;
	}
	
	public boolean search(Square target) {
		for (int i=0; i<SIZE; i++) {
			if (myShip[i].equals(target)) {
				// if an ideal square! need code here!
				//target.hit();
				//targetShip[i] = myShip[i];
				return true;
			}
		}
		//target.missed();
		return false;
	}
	
	public boolean isSunk() {
		if (myShip.equals(targetShip)) {
			return true;
		}
		//else
		return false;
	}
	
	public String toString() {
		String s = "\r\n";
		for (int i=0; i<SIZE; i++) {
			s = s + myShip[i].toString();
			if (orientation) {
				s = s + "\r\n";
			}
		}
		return s + "\r\n";
	}
}
